package com.maxlen.common.utils;

import com.alibaba.fastjson.JSON;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 打印输出返回给前端工具类
 */
public class ResponseUtils {
    public static void out(HttpServletResponse response, R r){
        try {
            response.setContentType("application/json;charset=utf-8");
            /*response.getWriter().print(JSON.toJSONString(r));*/
            PrintWriter writer = response.getWriter();
            writer.print(JSON.toJSONString(r));
            writer.flush();
            writer.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
